using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Attributes;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Attributes.DomainAttributes;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Enums;
using System.Collections.Generic;
using System.ComponentModel;

namespace Baci.ArcGIS._SpatialStatisticsTools._ModelingSpatialRelationships
{
    /// <summary>
    /// <para>Geographically Weighted Regression </para>
    /// <para>Performs Geographically Weighted Regression (GWR), a local form of linear regression used to model spatially varying relationships.</para>
    /// <para>执行地理加权回归 （GWR），这是一种局部形式的线性回归，用于对空间变化的关系进行建模。</para>
    /// </summary>    
    [DisplayName("Geographically Weighted Regression ")]
    public class GeographicallyWeightedRegression : AbstractGPProcess
    {
        /// <summary>
        /// 无参构造
        /// </summary>
        public GeographicallyWeightedRegression()
        {

        }

        /// <summary>
        /// 有参构造
        /// </summary>
        /// <param name="_in_features">
        /// <para>Input features</para>
        /// <para>The feature class containing the dependent and independent variables.</para>
        /// <para>包含因变量和自变量的要素类。</para>
        /// </param>
        /// <param name="_dependent_field">
        /// <para>Dependent variable</para>
        /// <para>The numeric field containing the values that will be modeled.</para>
        /// <para>包含将要建模的值的数值字段。</para>
        /// </param>
        /// <param name="_explanatory_field">
        /// <para>Explanatory variable(s)</para>
        /// <para>A list of fields representing independent explanatory variables in the regression model.</para>
        /// <para>表示回归模型中独立解释变量的字段列表。</para>
        /// </param>
        /// <param name="_out_featureclass">
        /// <para>Output feature class</para>
        /// <para>The output feature class that will receive dependent variable estimates and residuals.</para>
        /// <para>将接收因变量估计值和残差的输出要素类。</para>
        /// </param>
        /// <param name="_kernel_type">
        /// <para>Kernel type</para>
        /// <para><xdoc>
        ///   <para>Specifies whether the kernel is constructed as a fixed distance, or if it is allowed to vary in extent as a function of feature density.</para>
        ///   <bulletList>
        ///     <bullet_item>Fixed—The spatial context (the Gaussian kernel) used to solve each local regression analysis is a fixed distance.</bullet_item><para/>
        ///     <bullet_item>Adaptive—The spatial context (the Gaussian kernel) is a function of a specified number of neighbors. Where feature distribution is dense, the spatial context is smaller; where feature distribution is sparse, the spatial context is larger.</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>指定内核是构造为固定距离，还是允许内核的范围随要素密度的变化而变化。</para>
        ///   <bulletList>
        ///     <bullet_item>固定 - 用于求解每个局部回归分析的空间上下文（高斯核）为固定距离。</bullet_item><para/>
        ///     <bullet_item>自适应 - 空间上下文（高斯核）是指定数量的邻居的函数。要素分布较密集，空间环境较小;要素分布稀疏时，空间环境较大。</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// </param>
        /// <param name="_bandwidth_method">
        /// <para>Bandwidth method</para>
        /// <para><xdoc>
        ///   <para>Specifies how the extent of the kernel will be determined. When Akaike Information Criterion or Cross Validation is selected, the tool will find the optimal distance or number of neighbors. Typically, you will select either Akaike Information Criterion or Cross Validation when you aren't sure what to use for the Distance or Number of neighbors parameter. Once the tool determines the optimal distance or number of neighbors, however, you'll use the As specified below option.</para>
        ///   <bulletList>
        ///     <bullet_item>Akaike Information Criterion—The extent of the kernel is determined using the Akaike Information Criterion.</bullet_item><para/>
        ///     <bullet_item>Cross Validation—The extent of the kernel is determined using cross validation.</bullet_item><para/>
        ///     <bullet_item>As specified below—The extent of the kernel is determined by a fixed distance or a fixed number of neighbors. You must specify a value for either the Distance or Number of neighbors parameters.</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>指定如何确定内核的范围。选择 Akaike Information Criteria 或 Cross Validation 后，该工具将找到最佳距离或邻居数量。通常，当您不确定要将什么用于“距离”或“邻居数”参数时，将选择“赤池信息条件”或“交叉验证”。但是，一旦该工具确定了最佳距离或邻居数量，您将使用如下所示选项。</para>
        ///   <bulletList>
        ///     <bullet_item>Akaike 信息标准 - 内核的范围是使用 Akaike 信息标准确定的。</bullet_item><para/>
        ///     <bullet_item>交叉验证 - 使用交叉验证确定内核的范围。</bullet_item><para/>
        ///     <bullet_item>如下所述 - 内核的范围由固定距离或固定数量的邻居确定。必须为“距离”或“邻居数”参数指定一个值。</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// </param>
        public GeographicallyWeightedRegression(object _in_features, object _dependent_field, List<object> _explanatory_field, object _out_featureclass, _kernel_type_value _kernel_type, _bandwidth_method_value _bandwidth_method)
        {
            this._in_features = _in_features;
            this._dependent_field = _dependent_field;
            this._explanatory_field = _explanatory_field;
            this._out_featureclass = _out_featureclass;
            this._kernel_type = _kernel_type;
            this._bandwidth_method = _bandwidth_method;
        }
        public override string ToolboxName => "Spatial Statistics Tools";

        public override string ToolName => "Geographically Weighted Regression ";

        public override string CallName => "stats.GeographicallyWeightedRegression";

        public override List<string> AcceptEnvironments => ["cellSize", "geographicTransformations", "outputCoordinateSystem", "scratchWorkspace", "snapRaster", "workspace"];

        public override object[] ParameterInfo => [_in_features, _dependent_field, _explanatory_field, _out_featureclass, _kernel_type.GetGPValue(), _bandwidth_method.GetGPValue(), _distance, _number_of_neighbors, _weight_field, _coefficient_raster_workspace, _cell_size, _in_prediction_locations, _prediction_explanatory_field, _out_prediction_featureclass, _out_table, _out_regression_rasters];

        /// <summary>
        /// <para>Input features</para>
        /// <para>The feature class containing the dependent and independent variables.</para>
        /// <para>包含因变量和自变量的要素类。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Input features")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public object _in_features { get; set; }


        /// <summary>
        /// <para>Dependent variable</para>
        /// <para>The numeric field containing the values that will be modeled.</para>
        /// <para>包含将要建模的值的数值字段。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Dependent variable")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public object _dependent_field { get; set; }


        /// <summary>
        /// <para>Explanatory variable(s)</para>
        /// <para>A list of fields representing independent explanatory variables in the regression model.</para>
        /// <para>表示回归模型中独立解释变量的字段列表。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Explanatory variable(s)")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public List<object> _explanatory_field { get; set; }


        /// <summary>
        /// <para>Output feature class</para>
        /// <para>The output feature class that will receive dependent variable estimates and residuals.</para>
        /// <para>将接收因变量估计值和残差的输出要素类。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Output feature class")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public object _out_featureclass { get; set; }


        /// <summary>
        /// <para>Kernel type</para>
        /// <para><xdoc>
        ///   <para>Specifies whether the kernel is constructed as a fixed distance, or if it is allowed to vary in extent as a function of feature density.</para>
        ///   <bulletList>
        ///     <bullet_item>Fixed—The spatial context (the Gaussian kernel) used to solve each local regression analysis is a fixed distance.</bullet_item><para/>
        ///     <bullet_item>Adaptive—The spatial context (the Gaussian kernel) is a function of a specified number of neighbors. Where feature distribution is dense, the spatial context is smaller; where feature distribution is sparse, the spatial context is larger.</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>指定内核是构造为固定距离，还是允许内核的范围随要素密度的变化而变化。</para>
        ///   <bulletList>
        ///     <bullet_item>固定 - 用于求解每个局部回归分析的空间上下文（高斯核）为固定距离。</bullet_item><para/>
        ///     <bullet_item>自适应 - 空间上下文（高斯核）是指定数量的邻居的函数。要素分布较密集，空间环境较小;要素分布稀疏时，空间环境较大。</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Kernel type")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public _kernel_type_value _kernel_type { get; set; }

        public enum _kernel_type_value
        {
            /// <summary>
            /// <para>Fixed</para>
            /// <para>Fixed—The spatial context (the Gaussian kernel) used to solve each local regression analysis is a fixed distance.</para>
            /// <para>固定 - 用于求解每个局部回归分析的空间上下文（高斯核）为固定距离。</para>
            /// </summary>
            [Description("Fixed")]
            [GPEnumValue("FIXED")]
            _FIXED,

            /// <summary>
            /// <para>Adaptive</para>
            /// <para>Adaptive—The spatial context (the Gaussian kernel) is a function of a specified number of neighbors. Where feature distribution is dense, the spatial context is smaller; where feature distribution is sparse, the spatial context is larger.</para>
            /// <para>自适应 - 空间上下文（高斯核）是指定数量的邻居的函数。要素分布较密集，空间环境较小;要素分布稀疏时，空间环境较大。</para>
            /// </summary>
            [Description("Adaptive")]
            [GPEnumValue("ADAPTIVE")]
            _ADAPTIVE,

        }

        /// <summary>
        /// <para>Bandwidth method</para>
        /// <para><xdoc>
        ///   <para>Specifies how the extent of the kernel will be determined. When Akaike Information Criterion or Cross Validation is selected, the tool will find the optimal distance or number of neighbors. Typically, you will select either Akaike Information Criterion or Cross Validation when you aren't sure what to use for the Distance or Number of neighbors parameter. Once the tool determines the optimal distance or number of neighbors, however, you'll use the As specified below option.</para>
        ///   <bulletList>
        ///     <bullet_item>Akaike Information Criterion—The extent of the kernel is determined using the Akaike Information Criterion.</bullet_item><para/>
        ///     <bullet_item>Cross Validation—The extent of the kernel is determined using cross validation.</bullet_item><para/>
        ///     <bullet_item>As specified below—The extent of the kernel is determined by a fixed distance or a fixed number of neighbors. You must specify a value for either the Distance or Number of neighbors parameters.</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>指定如何确定内核的范围。选择 Akaike Information Criteria 或 Cross Validation 后，该工具将找到最佳距离或邻居数量。通常，当您不确定要将什么用于“距离”或“邻居数”参数时，将选择“赤池信息条件”或“交叉验证”。但是，一旦该工具确定了最佳距离或邻居数量，您将使用如下所示选项。</para>
        ///   <bulletList>
        ///     <bullet_item>Akaike 信息标准 - 内核的范围是使用 Akaike 信息标准确定的。</bullet_item><para/>
        ///     <bullet_item>交叉验证 - 使用交叉验证确定内核的范围。</bullet_item><para/>
        ///     <bullet_item>如下所述 - 内核的范围由固定距离或固定数量的邻居确定。必须为“距离”或“邻居数”参数指定一个值。</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Bandwidth method")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public _bandwidth_method_value _bandwidth_method { get; set; }

        public enum _bandwidth_method_value
        {
            /// <summary>
            /// <para>Akaike Information Criterion</para>
            /// <para>Akaike Information Criterion—The extent of the kernel is determined using the Akaike Information Criterion.</para>
            /// <para>Akaike 信息标准 - 内核的范围是使用 Akaike 信息标准确定的。</para>
            /// </summary>
            [Description("Akaike Information Criterion")]
            [GPEnumValue("AICc")]
            _AICc,

            /// <summary>
            /// <para>Cross Validation</para>
            /// <para>Cross Validation—The extent of the kernel is determined using cross validation.</para>
            /// <para>交叉验证 - 使用交叉验证确定内核的范围。</para>
            /// </summary>
            [Description("Cross Validation")]
            [GPEnumValue("CV")]
            _CV,

            /// <summary>
            /// <para>As specified below</para>
            /// <para>As specified below—The extent of the kernel is determined by a fixed distance or a fixed number of neighbors. You must specify a value for either the Distance or Number of neighbors parameters.</para>
            /// <para>如下所述 - 内核的范围由固定距离或固定数量的邻居确定。必须为“距离”或“邻居数”参数指定一个值。</para>
            /// </summary>
            [Description("As specified below")]
            [GPEnumValue("BANDWIDTH_PARAMETER")]
            _BANDWIDTH_PARAMETER,

        }

        /// <summary>
        /// <para>Distance</para>
        /// <para>The distance to use when the Kernel type parameter is set to Fixed and the Bandwidth method parameter is set to As specified below.</para>
        /// <para>当“内核类型”参数设置为“固定”，带宽方法参数设置为“如下所述”时要使用的距离。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Distance")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public double? _distance { get; set; } = null;


        /// <summary>
        /// <para>Number of neighbors</para>
        /// <para>The exact number of neighbors to include in the local bandwidth of the Gaussian kernel when the Kernel type parameter is set to Adaptive and the Bandwidth method parameter is set to As specified below.</para>
        /// <para>当“内核类型”参数设置为“自适应”且“带宽方法”参数设置为“如下所述”时，高斯核的本地带宽中要包含的邻居的确切数量。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Number of neighbors")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public long _number_of_neighbors { get; set; } = 30;


        /// <summary>
        /// <para>Weights</para>
        /// <para>The numeric field containing a spatial weighting for individual features. This weight field allows some features to be more important in the model calibration process than others. This is useful when the number of samples taken at different locations varies, values for the dependent and independent variables are averaged, and places with more samples are more reliable (should be weighted higher). If you have an average of 25 different samples for one location but an average of only 2 samples for another location, for example, you can use the number of samples as your weight field so that locations with more samples have a larger influence on model calibration than locations with few samples.</para>
        /// <para>包含各个要素的空间权重的数值字段。此权重字段允许某些特征在模型校准过程中比其他特征更重要。当在不同位置采集的样本数量不同，因变量和自变量的值取平均值，以及样本较多的地方更可靠（权重应更高）时，这很有用。例如，如果一个位置平均有 25 个不同的样本，但另一个位置平均只有 2 个样本，则可以使用样本数作为权重字段，以便样本较多的位置比样本较少的位置对模型校准的影响更大。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Weights")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public object _weight_field { get; set; } = null;


        /// <summary>
        /// <para>Coefficient raster workspace</para>
        /// <para>The full path to the workspace where the coefficient rasters will be created. When this workspace is provided, rasters are created for the intercept and every explanatory variable.</para>
        /// <para>将创建系数栅格的工作空间的完整路径。提供此工作空间后，将为截距和每个解释变量创建栅格。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Coefficient raster workspace")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public object _coefficient_raster_workspace { get; set; } = null;


        /// <summary>
        /// <para>Output cell size</para>
        /// <para><xdoc>
        ///   <para>The cell size (a number) or reference to the cell size (a path to a raster dataset) to use when creating the coefficient rasters.</para>
        ///   <para>The default cell size is the shortest of the width or height of the extent specified in the geoprocessing environment output coordinate system, divided by 250.</para>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>创建系数栅格时要使用的像元大小（数字）或对像元大小的引用（栅格数据集的路径）。</para>
        ///   <para>默认像元大小为地理处理环境输出坐标系中指定的范围宽度或高度的最短者除以 250。</para>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Output cell size")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public object _cell_size { get; set; } = null;


        /// <summary>
        /// <para>Prediction locations</para>
        /// <para>A feature class containing features representing locations where estimates should be computed. Each feature in this dataset should contain values for all of the explanatory variables specified; the dependent variable for these features will be estimated using the model calibrated for the input feature class data.</para>
        /// <para>包含表示应计算估计值位置的要素的要素类。此数据集中的每个要素都应包含所有指定解释变量的值;这些要素的因变量将使用为输入要素类数据校准的模型进行估计。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Prediction locations")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public object _in_prediction_locations { get; set; } = null;


        /// <summary>
        /// <para>Prediction explanatory variable(s)</para>
        /// <para>A list of fields representing explanatory variables in the Prediction locations feature class. These field names should be provided in the same order (a one-to-one correspondence) as those listed for the input feature class Explanatory variables parameter. If no prediction explanatory variables are given, the output prediction feature class will only contain computed coefficient values for each prediction location.</para>
        /// <para>表示预测位置要素类中解释变量的字段列表。这些字段名称的提供顺序（一对一对应）应与输入要素类解释变量参数所列的顺序相同。如果未给出预测解释变量，则输出预测要素类将仅包含每个预测位置的计算系数值。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Prediction explanatory variable(s)")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public List<object> _prediction_explanatory_field { get; set; } = null;


        /// <summary>
        /// <para>Output prediction feature class</para>
        /// <para>The output feature class to receive dependent variable estimates for each feature in the Prediction locations feature class.</para>
        /// <para>用于接收预测位置要素类中每个要素的因变量估计值的输出要素类。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Output prediction feature class")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public object _out_prediction_featureclass { get; set; } = null;


        /// <summary>
        /// <para>Output table</para>
        /// <para></para>
        /// <para></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Output table")]
        [Description("")]
        [Option(OptionTypeEnum.derived)]
        public object _out_table { get; set; }


        /// <summary>
        /// <para>Output regression rasters</para>
        /// <para></para>
        /// <para></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Output regression rasters")]
        [Description("")]
        [Option(OptionTypeEnum.derived)]
        public object _out_regression_rasters { get; set; }


        public GeographicallyWeightedRegression SetEnv(object cellSize = null, object geographicTransformations = null, object outputCoordinateSystem = null, object scratchWorkspace = null, object snapRaster = null, object workspace = null)
        {
            base.SetEnv(cellSize: cellSize, geographicTransformations: geographicTransformations, outputCoordinateSystem: outputCoordinateSystem, scratchWorkspace: scratchWorkspace, snapRaster: snapRaster, workspace: workspace);
            return this;
        }

    }

}